//
//  GDTrainViewModel.m
//  GraduationDesign
//
//  Created by JiaKang.Zhong on 16/1/7.
//  Copyright © 2016年 JiaKang.Zhong. All rights reserved.
//

#import "GDTrainViewModel.h"
#import "GDTrainInformationModel.h"

@implementation GDTrainViewModel



// 开始计算frame
-(void)setModel:(GDTrainInformationModel *)model{
    
    _model = model;
    /**
     *  计算开始站
     */
    CGFloat startStationX = GDMargin + 10;
    CGFloat startStationY = GDMargin ;
    CGFloat startStationW = 100;
    CGFloat startStationH = 60;
    _startStationViewFrame = CGRectMake(startStationX, startStationY,startStationW , startStationH);
    
    
    /**
     *  计算结束站
     */
    CGFloat endStationX = CGRectGetMaxX(_startStationViewFrame) + 10;
    CGFloat endStationY = GDMargin ;
    CGFloat endStationW = 100;
    CGFloat endStationH = 60;
    _endStationViewFrame = CGRectMake(endStationX, endStationY, endStationW, endStationH);
    
    /**
     *  计算车次
     */
    CGFloat trainNoX = CGRectGetMaxX(_endStationViewFrame) + 5;
    CGFloat trainNoY = GDMargin;
    CGFloat trainNoW = 100;
    CGFloat trainNoH = 30;
    _trainNoViewFrame = CGRectMake(trainNoX, trainNoY, trainNoW, trainNoH);
    
    /**
     *  计算类型
     */
    CGFloat trainTypeX = CGRectGetMaxX(_endStationViewFrame) + 5;
    CGFloat trainTypeY = CGRectGetMaxY(_trainNoViewFrame) + 5;
    CGFloat trainTypeW = 100;
    CGFloat trainTypeH = 30;
    _trainTypeViewFrame = CGRectMake(trainTypeX, trainTypeY, trainTypeW, trainTypeH);
    
    /**
     *  开始时间
     */
    CGFloat startTimeX = GDMargin;
    CGFloat startTimeY = CGRectGetMaxY(_startStationViewFrame) - 5;
    CGFloat startTimeW = 150;
    CGFloat startTimeH = 30;
    _trainStartTimeViewFrame = CGRectMake(startTimeX, startTimeY, startTimeW, startTimeH);

    
    /**
     *  结束时间
     */
    CGFloat endTimeX = CGRectGetMaxX(_trainStartTimeViewFrame) + 20;
    CGFloat endTimeY = CGRectGetMaxY(_startStationViewFrame) - 5;
    CGFloat endTimeW = 150;
    CGFloat endTimeH = 30;
    _trainEndTimeViewFrame = CGRectMake(endTimeX, endTimeY, endTimeW, endTimeH);
    
    
    /**
     *  没票的的情况
     */
    if (model.existTicketArray.count == 0) {
        CGFloat imageViewX = GDMargin * 8 + 50;
        CGFloat imageViewY = 0;
        CGFloat imageViewW = 140;
        CGFloat imageViewH = 140;
        _noTicketUIImageViewFrame = CGRectMake(imageViewX, imageViewY, imageViewW, imageViewH);
        
        CGFloat noTickerLabelX = GDMargin * 9 + 20;
        CGFloat noTickerLabelY = CGRectGetMaxY(_trainStartTimeViewFrame) + GDMargin;
        CGFloat noTickerLabelW = 200;
        CGFloat noTickerLabelH = 30;
        _noTicketLabelViewFrame = CGRectMake(noTickerLabelX, noTickerLabelY, noTickerLabelW, noTickerLabelH);

    }
    
    /**
     *  有票的情况
     */
    CGFloat tickViewX = GDMargin;
    CGFloat tickViewY = CGRectGetMaxY(_trainStartTimeViewFrame) - 5;
    CGFloat tickViewW = CGRectGetMaxX(_trainNoViewFrame);
    CGFloat tickViewH = 60;
    _ticketViewFrame = CGRectMake(tickViewX, tickViewY,tickViewW, tickViewH);
    

}


@end
